# Contributor: Francesco Colista <fcolista@alpinelinux.org>
# Maintainer: Francesco Colista <fcolista@alpinelinux.org>
pkgname=gns3-server
pkgver=2.2.19
pkgrel=0
pkgdesc="GNS3 network simulator. Server package"
url="https://github.com/GNS3/gns3-server"
arch="all !mips !mips64" # blocked by py3-py-cpuinfo
license="GPL-3.0-or-later"
depends="busybox dynamips python3
	py3-jsonschema-gns3
	py3-aiohttp-gns3
	py3-aiohttp-cors-gns3
	py3-aiofiles-gns3
	py3-jinja2
	py3-sentry-sdk
	py3-psutil-gns3
	py3-async-timeout-gns3
	py3-distro
	py3-py-cpuinfo-gns3
	py3-setuptools"

makedepends="busybox-static py3-setuptools python3-dev linux-headers"
subpackages="$pkgname-doc"
source="$pkgname-$pkgver.tar.gz::https://github.com/GNS3/gns3-server/archive/v$pkgver.tar.gz
requirements.patch"

build() {
	# Upstream includes busybox binary for x86_64. We want to replace it by
	# $CARCH binary
	if [ "$CARCH" != "x86_64" ] ; then
		busybox_bin=$(find . -name busybox -type f)
		cp /bin/busybox.static $busybox_bin
	fi
	python3 setup.py build
}

check() {
	python3 setup.py check
}

package() {
	python3 setup.py install --prefix=/usr --root="$pkgdir"
	mkdir -p "$pkgdir"/usr/share/doc/$pkgname
	cat >"$pkgdir"/usr/share/doc/$pkgname/README.alpine <<EOF
gns3-server has several optional packages that must be installed manually for additional functionality:

	apk add qemu
	apk add wiresark
	apk add ubridge
	apk add cpulimit
	apk add ubridge
	apk add vpcs
EOF
}

sha512sums="f42ece97f9da398f3ab62fb80e2b13a5a1e51d1964a65014932b585673964265e361c5f5fdfbc453858fc868bae8cdbb897f93738abbd12c1f3b037595306039  gns3-server-2.2.19.tar.gz
673402da09894ce05de40a46c208a2a8b69201febdf3f9eaba440ee4f5b3abedcb6ad3a7a86d9bf60986755292df049f1abc15462c869a099cdd45b0d2461f99  requirements.patch"
